package com.yt.app.provider.dao.impl;

import com.yt.app.core.model.Activity;
import com.yt.app.provider.dao.ActivityDao;
import com.yt.core.dao.GenericDaoImpl;

/**
 * Created by liujunshi on 16-1-22.
 */
public class ActivityDaoImpl extends GenericDaoImpl<Activity, Long> implements ActivityDao {
	public ActivityDaoImpl() {
		setNameSpace("com.yt.app.activity");
	}

	public Integer increaseUserCount(Long id){
		Activity activity = this.get(id);
		if(activity != null){
			activity.setUserCount(activity.getUserCount() + 1);
			this.getSqlSession().update(this.getNameSpace() + ".addUserCount", activity);
			return activity.getUserCount();
		}else{
			return -1;
		}
	}
}
